﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mail;
//using System.Net.Mail;
using System.Text;

namespace HitchHikersGuideToTheGalaxy.Helpers
{
    public class EmailAgent
    {
        private MailMessage mm = new MailMessage();
        private string mailTo = "";
        private string mailFrom = "";
        private string message = "";
        private string subject = "";

        public EmailAgent(string to, string from, string msg, string sub)
        {
            mailTo = to;
            mailFrom = from;
            message = msg;
            subject = sub;
        }

        public void SendEmail()
        {
            //Set the field of the mail

            mm.To = mailTo;
            mm.From = mailFrom;
            mm.Subject = subject;
            //mm.To.Add(mailTo);
            //mm.From.Address.Insert(0, mailFrom);

            //The body of the message text
            mm.Body = message;

            //Set the priority to normal
            mm.Priority = MailPriority.Normal;

            //Set the encoding of the mail
            mm.BodyEncoding = Encoding.UTF8;

            //Format of mail
            mm.BodyFormat = MailFormat.Html;

            // and then send the mail
            SmtpMail.Send(mm);
        }
    }
}
